# 项目主入口
from datetime import datetime

# 从db包中导入所需的功能
from db import (
    DuckDBHelper,
    insert_journal_info,
    insert_admission_info,
    insert_discharge_info,
    query_daily_ward_indicators,
    query_admission_info_mssql,
    query_discharge_info_mssql,
    merge_journal_info,
    query_month_journal
)

if __name__ == "__main__":
    # 示例：查询 SQL Server
    # sql = "SELECT * FROM [dz_his].[dbo].[gy_ksdm]"
    # df = query_sqlserver_df(sql)
    # if df is not None:5
    #     print("SQL Server 查询结果:")
    #     print(df)
    # else:
    #     print("SQL Server 无数据返回")

    # 示例：查询 DuckDB

    start_date = '2025-08-01'  # 使用标准日期格式
    end_date = '2025-08-31 23:59:59'    # 函数内部会自动添加时间部分

    # end_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    try:
        # insert_admission_info(start_date, end_date)
        # insert_discharge_info(start_date, end_date)
        insert_journal_info(start_date, end_date)
        # df=query_month_journal(start_date,end_date)
        print('ok')
    except Exception as e:
        print(f"导入失败：{e}")
    # df=merge_journal_info(start_date,end_date)

 